package com.hfkh.loop;

import java.util.Scanner;

public class ForDemo2 {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        System.out.print("请输入学员名字:");
        String name = input.next();
        float score = 0.0F;
        float total= 0.0f;
        float avg = 0.0f;
        float max = 0.0f;
        float min = 0.0f;
        //简答题：next()和nextLine()方法有什么不同
        for (int i = 1; i <= 5; i++) {
            System.out.print("请输入" + name +"的第" + i + "门课程的成绩:");
            score = input.nextFloat();
            total += score;

            /*
            * score = 85
            * min = 90
            * */
            if(i == 1){
                min = score;
            }
            if(score < min){
                min = score;
            }

            if(score > max){
                max = score;
            }
        }


        avg = total / 5;

        System.out.println(name + "的总成绩为：" + total + ",平均分为：" + avg + ",最高分为：" + max + ",最低分为：" + min);

    }
}
